package com.briup.mt.web.controller;

import com.briup.mt.bean.DatasetFile;
import com.briup.mt.service.DatasetFileService;
import com.briup.mt.utils.Message;
import com.briup.mt.utils.MessageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/datasetFile")
@Validated
public class DatasetFileController {
        @Autowired
        private DatasetFileService datasetFileService;

    @GetMapping("query")
    public Message query(String name,Long datasetId){
        List<DatasetFile> list = datasetFileService.query(name,datasetId);
        return MessageUtil.success(list);
    }


    @DeleteMapping("deleteById")
        public Message deleteById(long id) {
            datasetFileService.deleteById(id);
            return MessageUtil.success("删除成功！");
        }

        @PostMapping("saveOrUpdate")
        public Message saveOrUpdate(DatasetFile datasetFile){
            datasetFileService.saveOrUpdate(datasetFile);
            return MessageUtil.success("操作成功");
        }
}
